var roleManage = function() {

	var _init = function() {

		var table = $('#table_role');
		table
				.dataTable({
					"processing" : true,
					// 开启服务器模式
					serverSide : true,
					"ajax" : {
						url : "/a/msg/note"
					},
					"autoWidth" : false,
					"columns" : [
							/*{
								"width" : "15%",
								"data" : "id"
							},*/
							{
								"width" : "30%",
								"data" : "title",
								 "orderable": false,  
							},
							{
								"width" : "30%",
								"data" : "createDate"
							},
							{
								"width" : "40%",
								"data" : "null",
								"defaultContent" : "<button type=\"button\" class=\"btn blue btn_edit_role\">查看</button>"
							} ],
					"language" : {
						"lengthMenu" : "每页显示 _MENU_ 条记录",
						"emptyTable" : "暂无数据记录",
						"info" : "显示 _START_ 至 _END_ 条数据，共 _TOTAL_ 条记录！",
						"zeroRecords" : "没有搜索到匹配记录",
						"infoEmpty" : "",
						"infoFiltered" : "",
						"processing" : ""
					},
					"destroy" : true,
					"sort": false,
					"pageLength" : 5,
					"columnDefs" : [ {
						"orderable" : false,
						"targets" : [ 0, 1,2 ]
					}, {
						"targets" : 0,
						"render" : function(data, type, row, meta) {
							return data;
						}
					}, {
						"targets" : 1,
					"render" : function(data, type, row, meta) {
						return moment(data).format('YYYY-MM-DD HH:mm');
					}
					}, {
						"targets" : 2,
						"render" : function(data, type, row, meta) {
							return data;
						}
						
					} ],
					"dom" : "<'row'<'.col-md-6 col-sm-12'><'col-md-6 col-sm-12'>r>"
							+ "<t>" + "<'row'<'col-md-5'i><'col-md-7'>p>",
					"fnInitComplete" : function() {
					}
				});

		table.on('click', '.btn_edit_role', function(event) {
			var oData_arr = table.DataTable().rows($(this).parents("tr"))
			.data(); // 操作行对象
	var _id = oData_arr[0].id;
	var _isread = $("#isread").val();
			window.location.href = "/p/msg/note/reader?id="
					+ encodeURIComponent(_id)+"&isread="+_isread;
		});

		$("#doQuery").on("click", function(event) {
			var form = $('#form1').serializeObject();
			var param = {
				"IsRead" : form.isread,
			/*	"source" : form.source,*/
				"title" : form.title
			};
			$('#table_role').DataTable().search(JSON.stringify(param)).draw();
			// table.DataTable().ajax.reload();
		});

	}

	return {
		init : function() {
			_init();
		}

	};

}();

var roleForm = function() {
	// 新建表单验证
	return {
		init : function() {
		}

	};
}();

$(function() {
	roleManage.init();
	roleForm.init();
});


function beback() {
	window.location.href = "/p/msg/note";
}

function checkMsg() {
	roleManage.init();
}